
package com.dmai.capacity.platform.gateway.task;

import com.dmai.capacity.platform.oauth.common.service.IOauthUserBillService;
import com.dmai.capacity.platform.oauth.common.service.IOauthUserReportService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class OauthReportTask {

    @Autowired
    private IOauthUserBillService billService;

    @Autowired
    private IOauthUserReportService reportService;

    @Scheduled(cron = "${dmai.task.report.scheduled.cron:0 0 0/1 * * ?}")
    public void execute() {
        log.info("==start task==");
        try {
            //月账单
            billService.reCalculate();

            //日统计
            reportService.reCalculate();

        } catch (Exception e) {
            log.error("UserMonthBillTask error:{}", e.getMessage());
        }
        log.info("==end task==");
    }
}
